<?php
session_start();
include("connect.php");
if(!isset($_POST['strTFEMail']) || $_POST['strTFEMail']=='')
	exit;
$txtRcvrEmail=$_POST['strTFEMail'];

$txtSendrEmail=$_SESSION['email_id'];
//$txtSendrEmail=$_POST['strTFSMail'];
$res=mysql_query("select * from user_info where email_id='$txtSendrEmail'");
$row=mysql_fetch_object($res);
$txtSendrName="$row->first_name $row->last_name";

//$txtSendrName=$_POST['strTFSName'];

$txtMsg=$_POST['strTFMessage']; 
$query="insert into tell_friend(user_email,sender_name,receiver_email,sender_email,message) values('$_SESSION[email_id]','$txtSendrName','$txtRcvrEmail','$txtSendrEmail','$txtMsg')";
mysql_query($query);
include_once('../includes/class.phpmailer.php');
$mail = new PHPMailer();
//$mail->Host     = "smtp.emailsrvr.com";
//$mail->Mailer   = "smtp";
//$mail->Port = "587";
//$mail->SMTPDebug = "false";
//$mail->SMTPAuth = "true";
//$mail->SMTPKeepAlive = "true";
//$mail->Username = "a.namdeo@whizlabs.com";
//$mail->Password = "namdeo@4";
$mail->IsHTML(True);


//#######################################################################//
//################### Mail to Support ###################################//
//#######################################################################//
$support_email_to=$txtRcvrEmail;
$support_email_from=$txtSendrEmail;
$support_email_subject="semtimes.com - Your Friend recommends you to Play SEM Game at OM Careers. ";
$to="$support_email_to";
$mail->From     = $support_email_from;
$mail->FromName = $txtSendrName;
$mail->Subject	= "$support_email_subject";
$mail->Body = $txtMsg;
$mail->AddAddress($to, $txtSendrName);
if(!$mail->Send())
     echo "There has been a mail error." ;

// Clear all addresses and attachments for next loop.
$mail->ClearAddresses();
//######################################
header("location:../thank-you.html?msg=tellafriend");

?>